@echo off & cd /d "%~dp0"
@chcp 65001
setlocal enabledelayedexpansion

set "options[0]=system1"
set "options[1]=system2"
set "options[2]=system3"
set "options[3]=system4"
set "options[4]=system5"
set "options[5]=system6"

for /l %%i in (0,1,5) do (
    set selected[%%i]=0
)

set /a current=0

:menu
cls
echo W S上下选择，A D 取消选中/选中，Y提交 （英文输入法）
echo.

for /l %%i in (0,1,5) do (
    set /a sel=!selected[%%i]!
    if !current! equ %%i (
        if !sel! equ 1 (
            echo [*][X] !options[%%i]!
        ) else (
            echo [*][ ] !options[%%i]!
        )
    ) else (
        if !sel! equ 1 (
            echo [ ][X] !options[%%i]!
        ) else (
            echo [ ][ ] !options[%%i]!
        )
    )
)

choice /c wsadY /n /m "use English Input:"

set key=%errorlevel%

if %key% equ 1 (
    set /a current=!current!-1
    if !current! lss 0 set current=4
) else if %key% equ 2 (
    set /a current=!current!+1
    if !current! gtr 4 set current=0
) else if %key% equ 3 (
    set /a selected[%current%]=0
) else if %key% equ 4 (
    set /a selected[%current%]=1
) else if %key% equ 5 (
    goto submit
)

goto menu

:submit
cls
echo You selected:
for /l %%i in (0,1,5) do (
    set /a sel=!selected[%%i]!
    if !sel! equ 1 (
    powershell "code-insiders !options[%%i]!"
    wt -w 0 nt -d !options[%%i]! powershell "npm run dev"
    timeout /t 1 >nul
    )
)
exit
